<template>
  <div class="login_bg">
    <div class='login_box'>
      <p class="login_box_logo"><img src="../common/images/logo.png" alt=""></p>
      <p class="marginTop20">振德库存优化系统</p>
      <div class="login_text_box">
        <ul class="login_ul">
          <li style="position: relative;">
            <input type="text" placeholder="账户名称" class='admin' v-model="countName">
            <img src="../common/images/count.png" alt="">
          </li>
          <li style="position: relative;">
            <input type="password" class='admin_password' placeholder="账户密码" v-model="countPassword">
            <img src="../common/images/lock.png" alt="">
          </li>
        </ul>
        <div class="clearfix" style="width:4.3rem;margin:0rem auto">
          <p class="fl" v-on:click="register">注册</p>
          <p class="fr" @click="forgetPassword">忘记密码 <img src="../common/images/wen.png" alt=""></p>
        </div>
        <div class="tc">
          <button class="login_btn" @click="goIndex()">登&nbsp;&nbsp;&nbsp;录</button>
        </div>
        <!-- <div class="login_tip dn">用户名或密码错误</div>-->
      </div>
    </div>
  </div>
</template>
<script>
  import common from '../common/js/common';

  export default {
    data() {
      return {
        countName: '',
        countPassword: ''
      }
    },
    methods: {
      forgetPassword:function(){
        alert('请联系管理员')
      },      register: function () {
        this.$router.push({path: '/register'})
      },
      login:function(e){
				if(e.keyCode==13){
					this.goIndex();
				}
      },
      goIndex: function () {
        var _self = this;
        if (this.countName == '') {
          alert('用户名不能为空')
        } else if (this.countPassword == '') {
          alert('密码不能为空')
        } else {
          _self.$router.push({path: '/InventoryOverview'});
         /* var yx_data = {
            "employee_number": this.countName,
            "password": this.countPassword
          };
          common.getData(0, common.url_constitute.login, "post", yx_data, function (d) {
            if (d.data.code == 1024) {
              if(d.data.user_info.reset==1){
                _self.$router.push({path: '/rePassword'});
              }else{
                /!*权限控制*!/
                var role_id = d.data.user_info.role_id;
                localStorage.setItem("role_id",role_id);
                localStorage.setItem('employee_name',_self.countName);
                _self.$router.push({path: '/IntelligentFeedback'});
                switch(role_id){
                  case 2:
                    _self.$router.options.routes[2].children["0"].children[3].redirect.path = "/proposal";
                    break;
                  case 3:
                    _self.$router.options.routes[2].children["0"].children[3].redirect.path = "/proposal";
                    break;
                  case 4:
                    _self.$router.push({path: '/IntelligentFeedback'});
                    break;
                  default:
                    _self.$router.options.routes[2].children["0"].children[3].redirect.path = "/forecast";
                }
              }
            } else {
              alert(d.data.message);
            }
          });*/
        }
      },
    },
    mounted(){
    		var $this = this;
        $("body").keydown(function(e){
        	if(e.keyCode==13){
						$this.goIndex();
					}
        });
    }
  }
</script>
<style>
  @import "../common/css/base.css";
  @import "../common/css/yx-login.less";
</style>
